package com.typy.www.tpay.ui.itemview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.RadioButton;

import com.typy.www.tpay.R;
import com.typy.www.tpay.bean.vm.BuyConfigVm;
import com.typy.www.tpay.util.Logutil;
import com.typy.www.tpay.util.UpdataUiUtil;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 13799 on 2018/7/28.
 */

public class RadioItemView {
    private View mView;
    Context mContext;
    ViewHolder holder;
    Listener listener;
    public View getmView() {
        return mView;
    }

    public Listener getListener() {
        return listener;
    }

    public void setListener(Listener listener) {
        this.listener = listener;
    }

    public RadioItemView(Context context) {
        mContext = context;
        mView = LayoutInflater.from(context).inflate(R.layout.item_radio, null);
        holder=new ViewHolder(mView);
    }
    public void bind(BuyConfigVm vm , final int position){
        holder.rbs.setChecked(vm.isCheck());
        holder.rbs.setTextColor(vm.isCheck()?mContext.getResources().getColor(R.color.white):mContext.getResources().getColor(R.color.blue67BCFD));
        UpdataUiUtil.getDefaul().setText(vm.getFdAmount(),holder.rbs);

        holder.rbs.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.updata(position);
            }
        });
    }
    public interface Listener{
        void updata(int position);
    }

    static class ViewHolder {
        @BindView(R.id.rbs)
        RadioButton rbs;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
